<template>
	<view class="content">
		<view class="top">
			<view class="box">
				<view class="oderlist">
					<view class="subscription-item empty-box" v-if="orderdistributionlist.length == 0">
						<u-empty mode="list"></u-empty>
					</view>
					<view class="oderitem" v-for="item in orderdistributionlist" v-else>
						<view class="left">
							<u--image :showLoading="true" :src="item.goods_img" width="100rpx"
								height="100rpx"></u--image>
						</view>
						<view class="right">
							<view class="title">{{item.goods_name}}</view>
							<view class="time">购买时间：{{item.create_time}}</view>
							<view class="subscription">购买人：{{item.phone}}</view>
							<view class="text-money">
								<text class="text">收益：</text>
								<text class="money">¥{{item.earnings}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		gardMobile
	} from '@/utils/index.js'
	export default {
		data() {
			return {
				orderdistributionlist: [],
				paging: {
					page: 1,
					limit: 10,
				},
				total: null,
			}
		},
		onLoad() {
			this.getOrderDistribution()
		},
		onReachBottom() {
			this.getOrderDistribution()
		},
		onPullDownRefresh() {
			uni.startPullDownRefresh({
				success: () => this.refresh(),
				complete: () => uni.stopPullDownRefresh()
			})
		},
		methods: {
			getOrderDistribution() {
				if (this.orderdistributionlist.length == this.total) return
				this.$api.orderdistribution(this.paging).then(res => {
					const arr = res.data.list.map(item => {
						return {
							...item,
							phone: gardMobile(item.mobile)
						}
					})
					this.orderdistributionlist = [...this.orderdistributionlist, ...arr]
					this.total = res.data.total
					this.paging.page++
				}).catch(err=>{
				})
			},
			// 刷新列表
			refresh() {
				this.paging.page = 1
				this.total = null
				this.orderdistributionlist = []
				this.getOrderDistribution()
			},
		}
	}
</script>

<style scoped lang="scss">
	.top {
		padding-top: 20rpx
	}

	.content {
		background: #F5F5F5;
		min-height: 100vh;
		z-index: -1;

		.box {
			padding: 0 30rpx;
		}
	}

	.oderlist {
		min-height: 100vh;
		padding: 30rpx;
		background: #FFFFFF;
		border-radius: 10rpx;

		.oderitem {
			padding: 32rpx 0;
			display: flex;
			justify-content: space-between;
			border-bottom: 1rpx solid #dfdfdf;

			.left {
				width: 100rpx;
				height: 100rpx;
			}

			.right {
				padding-left: 30rpx;
				flex: 1;

				.title {
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
					font-size: 36rpx;
					color: #111111;
					line-height: 44rpx;
					text-align: left;
					font-style: normal;
				}

				.time {
					padding-top: 8rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 28rpx;
					color: #999999;
					line-height: 34rpx;
					text-align: left;
					font-style: normal;
				}

				.subscription {
					padding-top: 8rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 28rpx;
					color: #999999;
					line-height: 34rpx;
					text-align: left;
					font-style: normal;
				}

				.text-money {
					padding-top: 6rpx;

					.text {
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						font-size: 28rpx;
						color: #989898;
						line-height: 34rpx;
						text-align: left;
						font-style: normal;
					}

					.money {
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						font-size: 36rpx;
						color: #D06122;
						line-height: 44rpx;
						text-align: left;
						font-style: normal;
					}
				}
			}
		}
	}
</style>